<template>
    <div class="lzmlbt">
        <van-nav-bar :title="title" left-text="返回" left-arrow @click-left="onClickLeft" />
    </div>

    <div v-if="zjlist">
        <div class="container" v-for="(item, index) in zjlist" :key="index" @click="djtzzj(item?.serial_list, index)">
            <img :src="item?.cover" alt="" class="image">
            <div class="text-container">
                <div class="text-top">
                    {{ item?.title }}
                </div>
                <div class="text-bottom">
                    {{ item?.subtitle }}
                </div>
            </div>
        </div>
    </div>
</template>
  
<script setup>
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router'
import axios from '../plugins/axiosInstance';

const router = useRouter()
const title = ref('')
const id = ref('')
const zjlist = ref([])
const onClickLeft = () => history.back();
// 第一个参数是id列表，第二个是index，这样点击就能获取应该得到的id了
const djtzzj = (list, index) => {
    localStorage.setItem('lzwzxxId', JSON.stringify(list[index]))
    router.push(({ path: '/lzwzxx', query: { data: list[index] } }))
}

onMounted(() => {

    id.value = JSON.parse(localStorage.getItem('lzmuluId'))
    title.value = JSON.parse(localStorage.getItem('lzmulutitle'))
    axios({
        url: `https://apis.netstart.cn/one/find/serial/list/${id.value}`,
        method: 'get'
    }).then((res) => {
        zjlist.value = res?.data?.data
        console.log(zjlist.value);
    }).catch(() => { })
})
</script>
  
<style lang="less" scoped>
.container {
    box-sizing: border-box;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px;
}

.image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 10px;
}

.text-container {
    box-sizing: border-box;
    padding-left: 10px;
    padding-right: 10px;
    width: calc(100% - 50px);
    height: 50px;
}

.text-top {
    height: 50%;
    display: flex;
    align-items: center;
}

.text-bottom {
    width: 100%;
    height: 50%;
    color: #bebebe;
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 25px;
}
</style>